package com.zfast.forge.qlExpress;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;

/**
 * 公式枚举
 *
 * @author zgn
 * @date 2022/2/16 0016
 */
@Getter
public enum FormulaEnum {

    //region 速度坐标系解析
    VelocityDecomposition(
            "速度向量分解",
            "import com.zfast.forge.navigation.Coordinate;" +
                    "import com.zfast.forge.pojo.CustomBigDecimal;" +

                    "Xy=speed.x/speed.y;" +
                    "Zy=speed.z/speed.y;" +
                    "Yv=V/√([Xy,1,Zy]);" +
                    "Xv=Yv*Xy;" +
                    "Zv=Yv*Zy;" +

                    //判定方向
                    "Xv=speed.x>0?CustomBigDecimal.valueOf(Xv).abs():CustomBigDecimal.valueOf(Xv).abs().negate();" +
                    "Yv=speed.y>0?CustomBigDecimal.valueOf(Yv).abs():CustomBigDecimal.valueOf(Yv).abs().negate();" +
                    "Zv=speed.z>0?CustomBigDecimal.valueOf(Zv).abs():CustomBigDecimal.valueOf(Zv).abs().negate();" +

                    "String resultStr=Xv+\",\"+Yv+\",\"+Zv;" +
                    "Coordinate result = new Coordinate(resultStr);",

            "X,Y,Z,V",
            new String[]{"√"}
    ),
    //endregion

    //region 移动向量计算
    MovingPoint(
            "羽毛球移动三维坐标",
            "import com.zfast.forge.navigation.Coordinate;" +

                    "X=Vx*t+Ax*square(t)/2;" +
                    "Y=Vy*t+Ay*square(t)/2;" +
                    "Z=Vz*t+Az*square(t)/2;" +

                    "String resultStr=X+\",\"+Y+\",\"+Z;" +
                    "initial.move(new Coordinate(resultStr));",

            "initial,Vx,Vy,Vz,Ax,Ay,Az,t",
            new String[]{"square"}
    ),

    Boundary1(
            "单打场地边线",
            //X_l_t:(X;Y)_场地左右(l;r)_上(t;b;l;r)
            "Xlt=field.getX1();" +
                    "Xlb=field.getX1() + field.getX2() * 2;" +
                    "Yll=0;" +
                    "Ylr=field.getY1() + field.getY2() + field.getY3();" +

                    "Xrt=Xlt;" +
                    "Xrb=Xlb;" +
                    "Yrl=Ylr;" +
                    "Yrr=Ylr*2;" +

                    "result = [Xlt,Xlb,Yll,Ylr,Xrt,Xrb,Yrl,Yrr];"
    ),

    Boundary2(
            "双打场地边线",
            "Xlt=0;" +
                    "Xlb=(field.getX1() + field.getX2()) * 2;" +
                    "Yll=0;" +
                    "Ylr=field.getY1() + field.getY2() + field.getY3();" +

                    "Xrt=Xlt;" +
                    "Xrb=Xlb;" +
                    "Yrl=Ylr;" +
                    "Yrr=Ylr*2;" +

                    "result = [Xlt,Xlb,Yll,Ylr,Xrt,Xrb,Yrl,Yrr];"
    ),

    //2024年3月4日
    RunTime(
            //Tr:反应时间
            //Ts:启动时间
            //Tm:运动时间 +(2000-Tm)/50
            "T飞行",
            "(Tr+Ts);"
    ),

    //C为空气阻力系数；ρ为空气密度；S物体迎风面积；V为物体与空气的相对运动速度。
    AirResistanceCalculator(
            "空气阻力",
            //N
            "F=C*P*S*square(V)/2;" +
                    //转为cm/ms
                    "A=0-F/(M*square(10));" +
                    "return A;",
            "C,P,S,V",
            new String[]{"square"}
    ),

    ReactionTime(
            "反应时间",
            ""
    ),
    StartTime(
            "启动时间",
            ""
    ),
    convertHandStrengthToSpeed(
            "手部力量速度转化",
            "import com.zfast.forge.pojo.CustomBigDecimal;" +

                    "V=14*" +
                    "instance.getHand()/ 7840*" +
                    "instance.getHp()/7840;" +

                    "CustomBigDecimal.valueOf(V);"
    ),
    convertLegStrengthToSpeed(
            "腿部力量速度转化",
            ""
    ),
    Stamina(
            "耐力条",
            ""
    ),
    //region 测试
    //0.2689979286
    testHandStrengthToSpeed(
            "极限手部发力效率",
            //直接发力加速度
            "A=F/M;" +
                    //世界纪录发力加速度
                    "Am=V/T;" +
                    //折损率
                    "rate=Am/A"
    ),
    test002(
            "幂运算",
            "square(health)",
            "level,phase,health",
            new String[]{"square"}
    ),
    levelToHealth("生命转等级", "level*phase/health");
    //endregion

    @ApiModelProperty("描述")
    private String description;

    @ApiModelProperty("公式")
    private String value;

    @ApiModelProperty("入参")
    private String in;

    @ApiModelProperty("公式需要自定义运算符")
    private String[] functions;

    FormulaEnum(String description, String value, String in) {
        this.description = description;
        this.value = value;
        this.in = in;
    }

    /**
     * 多输入,输出公式
     *
     * @param description 描述
     * @param value       公式
     * @param in          多入参
     * @return null
     * @author zgn
     * @date 2024/2/29 0029
     */
    FormulaEnum(String description, String value, String in, String[] functions) {
        this.description = description;
        this.value = value;
        this.in = in;
        this.functions = functions;
    }

    /**
     * 单输出公式
     *
     * @param description 描述
     * @param value       公式
     * @return null
     * @author zgn
     * @date 2024/2/29 0029
     */
    FormulaEnum(String description, String value) {
        this.description = description;
        this.value = value;
    }
}
